package com.hottop.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hottop.common.annotation.Log;
import com.hottop.common.core.controller.BaseController;
import com.hottop.common.core.domain.AjaxResult;
import com.hottop.common.enums.BusinessType;
import com.hottop.system.domain.TWeibohot;
import com.hottop.system.service.ITWeibohotService;
import com.hottop.common.utils.poi.ExcelUtil;
import com.hottop.common.core.page.TableDataInfo;

/**
 * 微博热搜Controller
 * 
 * @author ruoyi
 * @date 2022-02-19
 */
@RestController
@RequestMapping("/system/weibohot")
public class TWeibohotController extends BaseController
{
    @Autowired
    private ITWeibohotService tWeibohotService;

    /**
     * 查询微博热搜列表
     */
    @PreAuthorize("@ss.hasPermi('system:weibohot:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWeibohot tWeibohot)
    {
        startPage();
        List<TWeibohot> list = tWeibohotService.selectTWeibohotList(tWeibohot);
        return getDataTable(list);
    }

    /**
     * 导出微博热搜列表
     */
    @PreAuthorize("@ss.hasPermi('system:weibohot:export')")
    @Log(title = "微博热搜", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWeibohot tWeibohot)
    {
        List<TWeibohot> list = tWeibohotService.selectTWeibohotList(tWeibohot);
        ExcelUtil<TWeibohot> util = new ExcelUtil<TWeibohot>(TWeibohot.class);
        util.exportExcel(response, list, "微博热搜数据");
    }

    /**
     * 获取微博热搜详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:weibohot:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tWeibohotService.selectTWeibohotById(id));
    }

    /**
     * 新增微博热搜
     */
    @PreAuthorize("@ss.hasPermi('system:weibohot:add')")
    @Log(title = "微博热搜", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWeibohot tWeibohot)
    {
        return toAjax(tWeibohotService.insertTWeibohot(tWeibohot));
    }

    /**
     * 修改微博热搜
     */
    @PreAuthorize("@ss.hasPermi('system:weibohot:edit')")
    @Log(title = "微博热搜", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWeibohot tWeibohot)
    {
        return toAjax(tWeibohotService.updateTWeibohot(tWeibohot));
    }

    /**
     * 删除微博热搜
     */
    @PreAuthorize("@ss.hasPermi('system:weibohot:remove')")
    @Log(title = "微博热搜", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tWeibohotService.deleteTWeibohotByIds(ids));
    }
}
